/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chromafinal;

/**
 *
 * @author Benjamin
 */

import java.awt.Color;
import java.awt.Graphics;

public class TeleportIn extends LevelBall{

    int xout, yout;

    public TeleportIn(int x, int y, int xout, int yout, int size)
    {
        super(x,y);
        this.size = size;
        this.xout = xout;
        this.yout = yout;
        otype = TELE;

        int lix = x-size/2;
        int lox = xout-size/3-2;
        int rix = x+size/2;
        int rox = xout+size/3+2;
        
        leftx = Math.min(lix,lox);
        rightx = Math.max(rix,rox);
    }

    public void pushPlayer(Player p)
    {
        if (distance(p) <= (size/2 - Player.SIZE_OF_MY_BALLS/2))
        {
            p.xl+= xout-x;
            p.yl+= yout-y;
        }
    }

    public void draw(Graphics g)
	{
            int i = Game.screenloc;
	    g.setColor( Color.BLUE );
	    g.fillOval((int) (x-size/2 - i), (int) (y-size/2), size, size);
            
            int d1 = size/3 +2;
            int d2 = size/3 -2;
            int [] xs = new int [] {xout-i-d1, xout-i-d2, xout-i+d1, xout-i+d2};
            int [] ys1 = new int [] {yout+d2,yout +d1, yout-d2, yout-d1};
            int [] ys2 = new int [] { yout-d2,yout -d1, yout+d2, yout+d1};
            g.fillPolygon(xs,ys1,4);
            g.fillPolygon(xs,ys2,4);
	}

    public boolean active()
    {
        return (xout - Game.screenloc > size/3+2 && xout+size/3+2 < Game.screenloc);
    }

    public String makeText(){
            String oput = super.makeText() + xout + "\t" + yout + "\t" + size + "\n";
            return oput;
	}

}
